<template>
  <div>
    <ul>
      <li v-for="(item, index) in sum" :key="item">
        <span>{{ item }}</span>
        <button @click="delFn(index)">删除</button>
      </li>
    </ul>
    <button @click="addFn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      sum: []
    }
  },
  methods: {
    addFn() {
      return this.sum.push(Math.floor(Math.random() * 20))
    },
    delFn(index) {
      return this.sum.splice(index, 1)
    }
  }
}
</script>

<style>

</style>